#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
    int n = 0;
    int x = 0;
    scanf("%d %d", &n, &x);
    int count = 0;
    for (int i = 1; i <= n; i++)
    {
        int m = i;
        while (m)
        {
            if (m % 10 == x)
            {
                count++;
            }
            m /= 10;
        }
    }
    printf("%d\n", count);
    return 0;
}